<template>
  <div class="container" v-loading="loading">
      <el-carousel :interval="4000" type="card" height="300px">
      <el-carousel-item v-for="(item, index) in img_list" :key="item.id">
        <h3 class="medium">
          <router-link :to="{
              name:'detail',
              params:{
                  id: item.id
		        }
             }"><img :src="item.url" alt="" class="imgs"/></router-link>
             </h3>
      </el-carousel-item>
    </el-carousel>
    <div class="slider-three leftfix" v-for="(dish, index)  in this.StapleFood" :key="dish.id">
            <div class="slider-wrapper-three">
              <router-link :to="{
              name:'detail',
              params:{
                  id: dish.id
              }
             }"><img  :src="require('../Home/images/'+dish.dishUrl)" alt="" style="width: 275px;height: 150px;"/></router-link>
            </div>
            <div class="slider-footer">
              <p>{{dish.dishName}}</p>
            </div>
          </div>
    </div>
</template>

<script>
import request from "@/utils/request";
export default {
  data() {
    return {
      img_list:[
              {"id": 31,"name":"鸡肉时蔬炒饭","url":require("@/pages/Home/images/鸡肉时蔬炒饭.jpg")},
              {"id": 32,"name":"辣白菜炒饭","url":require("@/pages/Home/images/辣白菜炒饭.jpg")},
              {"id": 33,"name":"排骨咸菜焖饭","url":require("@/pages/Home/images/排骨咸菜焖饭.jpg")},
              {"id": 34,"name":"羊腿炒饭","url":require("@/pages/Home/images/羊腿炒饭.jpg")},
            ],
      StapleFood:[],
      loading : true
    }
  },
  mounted(){
    request.get('dish/hotDishes/4')
    .then(res=>{
      if(res.data.code==1){
        this.StapleFood=res.data.data
        this.loading = false
      }
    })
    .catch(err=>{
      console.log(err)
    })
  }
}
</script>

<style scoped>
.container {
    width: 1160px;
    margin: 0 auto;
  }
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
  }

  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }

  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
  .slider-three{
  width: 275px;
  height: 195px;
  overflow: hidden;
  margin-left: 15px;
  margin-bottom: 20px;
  margin-top: 20px;
}
.slider-wrapper-three{
  width: 100%;
  height: 150px;
}
.slider-footer {
  height: 80px;
  background-color: rgb(100, 67, 68);
  padding: 12px 12px 0 12px;
  position: relative;
  line-height: 25px;
  text-align: center;
  color: white;
}
.imgs{
  width: 580px;
  height: 300px;
}
</style>
